Fix worktree branch selection context#2868
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit daf456a. Configure here.
ApprovabilityVerdict: Needs human review This PR changes runtime behavior for worktree branch selection - removing the logic that switched to the main repo when selecting a default branch from a worktree. While scoped and well-tested, this behavioral change in a non-trivial feature area warrants human review. You can customize Macroscope's approvability policy. Learn more. |

Summary
Verification
Note
Medium Risk
Changes thread/workspace routing for branch selection in worktree mode; wrong paths could check out the wrong directory, but scope is limited to BranchToolbar logic and covered by unit tests.
Overview
resolveBranchSelectionTargetno longer treats default branches specially when the selected ref has no mapped worktree. Branch switches stay in the active thread worktree (checkoutCwd/nextWorktreePathuseactiveWorktreePath ?? activeProjectCwd) instead of jumping to the main repo checkout. Behavior when the ref already has aworktreePathis unchanged, including clearingnextWorktreePathwhen that path is the main project cwd.The function’s
refNameinput dropsisDefault; onlyworktreePathdrives routing. Regression tests inBranchToolbar.logic.test.tsare updated to match the merged “no existing worktree” scenario.Reviewed by Cursor Bugbot for commit a17ba18. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
resolveBranchSelectionTargetto keep checkout in current worktree when selected ref has no existing worktreePreviously,
resolveBranchSelectionTargetin BranchToolbar.logic.ts would switch to the main repo when the selected ref was a default ref with no existing worktree. Now, when no existing worktree is found for the selected ref, checkout always stays in the active worktree andnextWorktreePathis set to the active worktree path. TheisDefaultfield is removed from therefNameinput type as it is no longer needed.Macroscope summarized a17ba18.